local skel = fk.CreateSkill {
  name = "emo__dianjijs",
}

Fk:loadTranslationTable{
  ["emo__dianjijs"] = "电击箭矢",
  [":emo__dianjijs"] = "出牌阶段限一次，你可以弃一张【杀】并横置两名角色，令其同时选择一项：弃一张牌；摸两张牌并受到你造成的一点雷电伤害。",

  ["#emo__dianjijs"] = "电击箭矢:弃1张【杀】并横置2名角色",
  ["#emo__dianjijs-discard"] = "电击箭矢：你需弃1张牌，否则摸2牌并受到雷电伤害",

  ["$emo__dianjijs1"] = "",
  ["$emo__dianjijs2"] = "",
}

skel:addEffect("active", {
  anim_type = "offensive",
  prompt = "#emo__dianjijs",
  card_num = 1,
  target_num = 2,
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).trueName == "slash"
    and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function (self, player, to_select, selected)
    return #selected < 2 and not to_select.chained
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local tos = table.simpleClone(effect.tos)
    room:sortByAction(tos)
    room:throwCard(effect.cards, skel.name, player, player)
    for _, p in ipairs(tos) do
      if not p.dead and not p.chained then
        p:setChainState(true)
      end
    end
    tos = room:deadPlayerFilter(tos)
    if #tos == 0 then return end
    local ret = room:askToJointCards(player, {
      pattern = ".", will_throw = true, min_num = 1, max_num = 1, skill_name = skel.name, players = tos,
      prompt = "#emo__dianjijs-discard", cancelable = true,
    })
    local moves = {}
    for from, ids in pairs(ret) do
      if #ids > 0 then
        table.insert(moves, {
          ids = ids,
          from = from,
          toArea = Card.DiscardPile,
          moveReason = fk.ReasonDiscard,
          skillName = skel.name,
          proposer = from,
        })
      end
    end
    if #moves > 0 then
      room:moveCards(table.unpack(moves))
    end
    for _, p in ipairs(tos) do
      if #ret[p] == 0 and not p.dead then
        p:drawCards(2, skel.name)
        if not p.dead then
          room:damage { from = player, to = p, damage = 1, skillName = skel.name, damageType = fk.ThunderDamage }
        end
      end
    end
  end,
})

return skel
